# encoding=UTF-8
from .mysqlconn import conn

print('df')


def inserttable(word_lst, dbname, cid):
    sql = ' insert into zy_robot_greeting(greetingques,greetingans) VALUES ("' + word_lst[0] + '","' + word_lst[
        1] + '"); '
    seq = conn.mysql_insertid(sql, dbname, cid)

    print(seq)


f = open("hanxuanyu.txt", 'r', encoding='utf-8')  # 返回一个文件对象
line = f.readline()
word_lst = []
##num = 1
##data = 1
nl = 0
for i in f:
    nl += 1
    # if nl <5791:
    if nl < 5817:
        if i.strip() == 'E':
            inserttable(word_lst)
            word_lst = []
        elif i[:1].strip() == 'M':
            word_lst.append(i[2:].strip())
        else:
            pass
    else:
        print('end')
##    else:''
##        pass


print('df===========')
f.close()
